{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e28c5c1b-ebd2-4b04-9a75-5c111646fc1f",
   "metadata": {},
   "source": [
    "# A heading\n",
    "\n",
    "This is a Markdown cell"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a70f791b-e2bd-4784-a204-153311ef9e22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\r\n",
       "<div>\r\n",
       "    <div id='dotnet-interactive-this-cell-14060.Microsoft.DotNet.Interactive.Http.HttpPort' style='display: none'>\r\n",
       "        The below script needs to be able to find the current output cell; this is an easy method to get it.\r\n",
       "    </div>\r\n",
       "    <script type='text/javascript'>\r\n",
       "async function probeAddresses(probingAddresses) {\r\n",
       "    function timeout(ms, promise) {\r\n",
       "        return new Promise(function (resolve, reject) {\r\n",
       "            setTimeout(function () {\r\n",
       "                reject(new Error('timeout'))\r\n",
       "            }, ms)\r\n",
       "            promise.then(resolve, reject)\r\n",
       "        })\r\n",
       "    }\r\n",
       "\r\n",
       "    if (Array.isArray(probingAddresses)) {\r\n",
       "        for (let i = 0; i < probingAddresses.length; i++) {\r\n",
       "\r\n",
       "            let rootUrl = probingAddresses[i];\r\n",
       "\r\n",
       "            if (!rootUrl.endsWith('/')) {\r\n",
       "                rootUrl = `${rootUrl}/`;\r\n",
       "            }\r\n",
       "\r\n",
       "            try {\r\n",
       "                let response = await timeout(1000, fetch(`${rootUrl}discovery`, {\r\n",
       "                    method: 'POST',\r\n",
       "                    cache: 'no-cache',\r\n",
       "                    mode: 'cors',\r\n",
       "                    timeout: 1000,\r\n",
       "                    headers: {\r\n",
       "                        'Content-Type': 'text/plain'\r\n",
       "                    },\r\n",
       "                    body: probingAddresses[i]\r\n",
       "                }));\r\n",
       "\r\n",
       "                if (response.status == 200) {\r\n",
       "                    return rootUrl;\r\n",
       "                }\r\n",
       "            }\r\n",
       "            catch (e) { }\r\n",
       "        }\r\n",
       "    }\r\n",
       "}\r\n",
       "\r\n",
       "function loadDotnetInteractiveApi() {\r\n",
       "    probeAddresses([\"http://192.168.1.16:1001/\", \"http://100.64.233.241:1001/\", \"http://172.30.32.1:1001/\", \"http://172.20.112.1:1001/\", \"http://172.19.32.1:1001/\", \"http://172.24.64.1:1001/\", \"http://127.0.0.1:1001/\"])\r\n",
       "        .then((root) => {\r\n",
       "        // use probing to find host url and api resources\r\n",
       "        // load interactive helpers and language services\r\n",
       "        let dotnetInteractiveRequire = require.config({\r\n",
       "        context: '14060.Microsoft.DotNet.Interactive.Http.HttpPort',\r\n",
       "                paths:\r\n",
       "            {\r\n",
       "                'dotnet-interactive': `${root}resources`\r\n",
       "                }\r\n",
       "        }) || require;\r\n",
       "\r\n",
       "            window.dotnetInteractiveRequire = dotnetInteractiveRequire;\r\n",
       "\r\n",
       "            window.configureRequireFromExtension = function(extensionName, extensionCacheBuster) {\r\n",
       "                let paths = {};\r\n",
       "                paths[extensionName] = `${root}extensions/${extensionName}/resources/`;\r\n",
       "                \r\n",
       "                let internalRequire = require.config({\r\n",
       "                    context: extensionCacheBuster,\r\n",
       "                    paths: paths,\r\n",
       "                    urlArgs: `cacheBuster=${extensionCacheBuster}`\r\n",
       "                    }) || require;\r\n",
       "\r\n",
       "                return internalRequire\r\n",
       "            };\r\n",
       "        \r\n",
       "            dotnetInteractiveRequire([\r\n",
       "                    'dotnet-interactive/dotnet-interactive'\r\n",
       "                ],\r\n",
       "                function (dotnet) {\r\n",
       "                    dotnet.init(window);\r\n",
       "                },\r\n",
       "                function (error) {\r\n",
       "                    console.log(error);\r\n",
       "                }\r\n",
       "            );\r\n",
       "        })\r\n",
       "        .catch(error => {console.log(error);});\r\n",
       "    }\r\n",
       "\r\n",
       "// ensure `require` is available globally\r\n",
       "if ((typeof(require) !==  typeof(Function)) || (typeof(require.config) !== typeof(Function))) {\r\n",
       "    let require_script = document.createElement('script');\r\n",
       "    require_script.setAttribute('src', 'https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js');\r\n",
       "    require_script.setAttribute('type', 'text/javascript');\r\n",
       "    \r\n",
       "    \r\n",
       "    require_script.onload = function() {\r\n",
       "        loadDotnetInteractiveApi();\r\n",
       "    };\r\n",
       "\r\n",
       "    document.getElementsByTagName('head')[0].appendChild(require_script);\r\n",
       "}\r\n",
       "else {\r\n",
       "    loadDotnetInteractiveApi();\r\n",
       "}\r\n",
       "\r\n",
       "    </script>\r\n",
       "</div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "output\n"
     ]
    }
   ],
   "source": [
    "Console.Out.WriteLine(\"output\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "fa84310c-0189-415c-b628-50a69b2ecd44",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "error\n"
     ]
    }
   ],
   "source": [
    "Console.Error.WriteLine(\"error\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "8e05dfb8-99a4-4ca1-9540-9615f7199018",
   "metadata": {},
   "outputs": [
    {
     "ename": "Unhandled exception",
     "evalue": "System.Exception: oops!\r\n   at Submission#5.<<Initialize>>d__0.MoveNext()\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)",
     "output_type": "error",
     "traceback": [
      "System.Exception: oops!\r\n   at Submission#5.<<Initialize>>d__0.MoveNext()\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)",
      "   at Submission#5.<<Initialize>>d__0.MoveNext()",
      "--- End of stack trace from previous location ---",
      "   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)"
     ]
    }
   ],
   "source": [
    "throw new Exception(\"oops!\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "5fb03543-a4c3-4dd3-961d-fd3c6074c651",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A return value"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"A return value\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a119c408-31f9-4286-86bf-cc434a7762a4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<b>\n",
       "    An HTML display value\n",
       "</b>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "@\"<b>\n",
    "    An HTML display value\n",
    "</b>\".DisplayAs(\"text/html\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "52ff47a2-2a22-4d7d-ac2f-06dd65c41d48",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A plaintext display value"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"A plaintext display value\".DisplayAs(\"text/plain\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "8feb3c15-4bb0-4fe1-89fe-a54c201cb6bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A plaintext display value (in a multi-output cell)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<b>\n",
       "    An HTML display value (in a multi-output cell)\n",
       "</b>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"A plaintext display value (in a multi-output cell)\".DisplayAs(\"text/plain\");\n",
    "\n",
    "@\"<b>\n",
    "    An HTML display value (in a multi-output cell)\n",
    "</b>\".DisplayAs(\"text/html\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8db2560d-1d3c-40d7-9e5f-6ea9799702c1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "file_extension": ".cs",
   "mimetype": "text/x-csharp",
   "name": "C#",
   "pygments_lexer": "csharp",
   "version": "10.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
